Shellsort with three increments

نویسندگان

  • Svante Janson
  • Donald E. Knuth
چکیده

A perturbation technique can be used to simplify and sharpen A. C. Yao's theorems about the behavior of shellsort with increments (h; g; 1). In particular, when h = (n 7=15) and g = (h 1=5), the average running time is O(n 23=15). The proof involves interesting properties of the inversions in random permutations that have been h-sorted and g-sorted. Shellsort, also known as the \diminishing increment sort" 7, Algorithm 5.2.1D], puts the elements of an array (X 0 ; : : : ; X n?1) into order by successively performing a straight insertion sort on larger and larger subarrays of equally spaced elements. The algorithm consists of t passes deened by increments (h t?1 ; : : : ; h 1 ; h 0), where h 0 = 1; the jth pass makes X k X l whenever l ? k = h t?j. A. C. Yao 11] has analyzed the average behavior of shellsort in the general three-pass case when the increments are (h; g; 1). The most interesting part of his analysis dealt with the third pass, where the running time is O(n) plus a term proportional to the average number of inversions that remain after a random permutation has been h-sorted and g-sorted. Yao proved that if g and h are relatively prime, the average number of inversions remaining is where the constant implied by b O depends on g and h. He gave a complicated triple sum for (h; g), which is too diicult to explain here; we will show that Moreover, we will prove that the average number of inversions after such h-sorting and g-sorting is The main technique used in proving (0.3) is to consider a stochastic algorithm A whose output has the same distribution as the inversions of the third pass of shellsort. Then by slightly perturbing the probabilities that deene A, we will obtain an algorithm A whose output has the expected value (h; g)n exactly. Finally we will prove that the perturbations cause the expected value to change by at most O(g 3 h 2). Section 1 introduces basic techniques for inversion counting, and section 2 adapts those techniques to a random input model. Section 3 proves that the crucial random variables needed for inversion counting are nearly uniform; then section 4 shows that the leading term (h; g)n in (0.3) would be exact if those variables were perfectly uniform. …

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

The Worst Case in Shellsort and Related Algorithms

We show that sorting a sufficiently long list of length N using Shellsort with m increments (not necessarily decreasing) requires at least N √ m comparisons in the worst case, for some constant c > 0. For m ≤ (log N/ log log N) we obtain an upper bound of the same form. We also prove that Ω(N(log N/ log log N)) comparisons are needed regardless of the number of increments. Our approach is gener...

متن کامل

Best Increments for the Average Case of Shellsort

This paper presents the results of using sequential analysis to find increment sequences that minimize the average running time of Shellsort, for array sizes up to several thousand elements. The obtained sequences outperform by about 3% the best ones known so far, and there is a plausible evidence that they are the optimal ones.

متن کامل

Improved Lower Bounds for Shellsort

We give improved lower bounds for Shellsort based on a new and relatively simple proof idea. The lower bounds obtained are both stronger and more general than the previously known bounds. In particular, they hold for nonmonotone increment sequences and adaptive Shellsort algorithms, as well as for some recently proposed variations of Shellsort.

متن کامل

Average-Case Complexity of Shellsort

We prove a general lower bound on the average-case complexity of Shellsort: the average number of data-movements (and comparisons) made by a p-pass Shellsort for any incremental sequence is Ω(pn 1 p ) for all p ≤ logn. Using similar arguments, we analyze the average-case complexity of several other sorting algorithms.

متن کامل

Analysis of Shellsort and Related Algorithms

This is an abstract of a survey talk on the theoretical and empirical studies that have been done over the past four decades on the Shellsort algorithm and its variants. The discussion includes: upper bounds, including linkages to number-theoretic properties of the algorithm; lower bounds on Shellsort and Shellsort-based networks; average-case results; proposed probabilistic sorting networks ba...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • Random Struct. Algorithms

دوره 10  شماره 

صفحات  -

تاریخ انتشار 1997